/*
 * @Description: 
 * @Author: liuzl
 * @Date: 2024-09-03 16:19:23
 * @LastEditors: liuzl
 * @LastEditTime: 2024-09-03 16:25:47
 */
import java.util.Scanner;
public class Test{
public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int y=sc.nextInt();
    int m=sc.nextInt();
    int d=sc.nextInt();
    int[]md =new int[]{31,28,31,30,31,30,31,31,30,31,30,31};
    int[]leepyearmd =new int[]{31,29,31,30,31,30,31,31,30,31,30,31};
    int ans =0;
    if(y%4==0&&y%100!=0||y%400==0){//闰年
    for(int i=0;i<m-1;i ++)
    ans += leepyearmd[i];
    ans += d;
    }else{
    for(int i=0;i<m-1;i ++)
    ans += md[i];
    ans += d;
}
System.out.println(ans);
}
}